<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		

		<title>提交报修申请</title>

		<link rel="stylesheet"
			href="<%=request.getContextPath()%>/css/common.css" type="text/css" />
		<script type="text/javascript"
			src="<%=request.getContextPath()%>/js/N13FormValidation-2.js"></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/interface/maintainReportTypeAction.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/engine.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/util.js'></script>
		<script type="text/javascript">
			window.onload=init;
			function init(){
				setSelectionList();
			}
			/**
			* 给apart select框赋值的
			*/
			function setSelectionList() {
				maintainReportTypeAction.getAllMaintainRepotType(ritCallBack);
			}
			var ritCallBack = function setList(ritList)//回调函数
			{				
				var s=$("maintainReportTypeName");
				DWRUtil.removeAllOptions(s); 
				s.options[0] = new Option("请选择保修物品类型",'0');
				for ( var i = 1; i < ritList.length+1; i++) {
					var opt = new Option(ritList[i-1].maintainreporttypename,
							ritList[i-1].maintainreporttypeid);
					s.options[i] = opt;
				}
			}
			/**
			* 公寓select框change函数
			*/
			function selectChange(){
				
			}
			
			function checkOnSubmit(){
			var studentName=window.top.frames['apt'].frames['maintain'].document.getElementById("stuName").innerHTML;
			document.getElementById("maintainreporter").value=studentName;
			alert(document.getElementById("maintainreporter").value);
				if(""==studentName){
						alert("请输入学生姓名！！");
						return false;
					}
				var time1= dojo.widget.byId("maintainreportavailtime");
				if("" == time1.getValue()){
					alert("维修预约时间不能为空");
					return false;
				}
				var selectedIndex=dwr.util.getValue("maintainReportTypeName");
				if(0==selectedIndex){
					alert("请选择物品类型！！");
					return false;
				}else{
					return true;
				}
			}
		</script>

		<s:head />
	</head>

	<body>
		<div id="page_container">
			<jsp:include page="registerinfonav.jsp"></jsp:include>
		
			<div id="content">
				<h2>
					提交报修申请
				</h2>
				<br />
				<s:form id="maintainreport" name="maintainreport"
					action="maintainreportinsert.action" method="post"
					theme="simple" onsubmit="return checkOnSubmit()">
					<table class="table_common">
					<s:hidden name="mr.maintainreporter" id="maintainreporter"></s:hidden>
						<tr class="">
							<td class="td_left">
								*报修人联系方式：
							</td>
							<td class="td_right">
								<s:textfield id="maintainreporterphone"
									name="mr.maintainreporterphone" />
							</td>
						</tr>
						<tr>
							<td class="td_left">
								* 报修地点：
							</td>
							<td class="td_right">
								<s:textfield id="maintainreportplace" label="宿舍信息："
									name="mr.maintainreportplace" />
								示例：9#109
							</td>
						</tr>
						<tr>
							<td class="td_left">
								* 报修类别：
							</td>
							<td class="td_right">
								<select class="common_select" id="maintainReportTypeName"
									name="mr.maintainreporttype.maintainreporttypeid"
									style="width: 150px">
								</select>
							</td>
						</tr>
						<tr>
							<td class="td_left">
								*维修预约时间：
							</td>
							<td class="td_right">
								<s:datetimepicker id="maintainreportavailtime"
									name="mr.maintainreportavailtime" displayFormat="yyyy-MM-dd"></s:datetimepicker>
							</td>
						</tr>
						<tr>
							<td class="td_left">
								报修详情：
							</td>
							<td class="td_right">
								<s:textarea label="维修内容：" name="mr.maintainreportcontent"
									cols="30" rows="3"></s:textarea>
							</td>
						</tr>
						<tr>
							<td class="table_submit" colspan="2">
								<s:submit cssClass="common_button" name="maintainreportsubmit"
									value="提交" onclick="return validateNull()"></s:submit>
							</td>
						</tr>
					</table>
				</s:form>
			</div>
			<script type="text/javascript">				
			     N13.register('maintainreport',[      
			 
			     {
			         id:'maintainreportplace',                                
			         type:'Required',                                        
			         validMsg:'√',                                             
			         invalidMsg:'请不要为空',                                
			         validOnBlur:true,                                       
			         renderValid:true                                    
			     },
			     {
			         id:'maintainreporterphone',                               
			         type:'Required',                                        
			         validMsg:'√',                                             
			         invalidMsg:'请不要为空',                                
			         validOnBlur:true,                                       
			         renderValid:true                                 
			     },
			     {
			         id:'maintainreporterphone',
			         type:'format',                                                //正则校验
			         validMsg:'√',
			         validOnBlur:true,
			         renderValid:true,
			         pattern: /^[0-9]*[1-9][0-9]*$/i                    //用正则表达式规定格式，注意写法：/正则表达式/i
			     }
			    
			     ]);     
     		</script>
		</div>
	</body>
</html>
